---
title: Formatter
emoji: 🖌️
category: tools
description: How to use the Rome formatter.
---

import PackageManagerRomeCommand from "@src/components/PackageManagerRomeCommand.astro";

# Formatter

Rome's an opinionated formatter that has the goal to stop all ongoing debates over styles. It follows a similar [philosophy to Prettier](https://prettier.io/docs/en/option-philosophy.html), only supporting
few options to avoid that debates over styles turn into debates over Rome options. It deliberately [resists the urge to add new options](https://github.com/prettier/prettier/issues/40) to prevent [bike-shed discussions](https://en.wikipedia.org/wiki/Law_of_triviality) in teams so they can focus on what really matters instead.

## Options

The language agnostic options supported by Rome are:

- indent style (default: `tab`): Use spaces or tabs for indention
- tab width (default: `2`): The number of spaces per indention level
- line width (default: `80`): The column width at which Rome wraps code

Other formatting options are available for specific languages as well.  See the [configuration](/configuration) options for details.

## Use the formatter with the CLI

You can start by running the CLI with the `--help` flag:

<PackageManagerRomeCommand command="format --help" />

Which will show you the options available at the moment:

```plaintext
Run the formatter on a set of files.

Usage: [--write] <PATH>...

Available positional items:
    <PATH>  Single file, single path or list of paths

Available options:
        --indent-style <tab|space>  The indent style.
        --indent-size <NUMBER>  The size of the indentation, 2 by default
        --line-width <NUMBER>  What's the max width of a line. Defaults to 80.
        --quote-style <double|single>  The style for quotes. Defaults to double.
        --quote-properties <preserve|as-needed>  When properties in objects are quoted. Defaults to
                       asNeeded.
        --trailing-comma <all|es5|none>  Print trailing commas wherever possible in multi-line
                       comma-separated syntactic structures. Defaults to "all".
        --semicolons <always|as-needed>  Whether the formatter prints semicolons for all statements
                       or only in for statements where it is necessary because of ASI.
        --vcs-client-kind <git>  The kind of client.
        --vcs-enabled <true|false>  Whether Rome should integrate itself with the VCS client
        --vcs-use-ignore-file <true|false>  Whether Rome should use the VCS ignore file. When [true],
                       Rome will ignore the files specified in the ignore file.
        --vcs-root <PATH>  The folder where Rome should check for VCS files. By default, Rome will
                       use the same folder where `rome.json` was found. If Rome can't fine the
                       configuration, it will attempt to use the current working directory. If no
                       current working directory can't be found, Rome won't use the VCS integration.
        --files-max-size <NUMBER>  The maximum allowed size for source code files in bytes. Files
                       above this limit will be ignored for performance reason. Defaults to 1 MiB
        --stdin-file-path <PATH>  A file name with its extension to pass when reading from standard
                       in, e.g. echo 'let a;' | rome format --stdin-file-path=file.js"
        --colors <off|force>  Set the formatting mode for markup: "off" prints everything as plain
                       text, "force" forces the formatting of markup using ANSI even if the console
                       output is determined to be incompatible
        --use-server   Connect to a running instance of the Rome daemon server.
        --verbose      Print additional verbose advices on diagnostics
        --config-path <PATH>  Set the filesystem path to the directory of the rome.json configuration
                       file
        --max-diagnostics <NUMBER>  Cap the amount of diagnostics displayed (default: 20)
        --skip-errors  Skip over files containing syntax errors instead of emitting an error
                       diagnostic.
        --json         Reports information using the JSON format
        --write
    -h, --help         Prints help information
```

## Configuration

You may want to [configure rome](/configuration/#formatter) using `rome.json`. The following defaults are applied:

```json
{
  "formatter": {
    "enabled": true,
    "formatWithErrors": false,
    "indentStyle": "tab",
    "indentSize": 2,
    "lineWidth": 80,
    "ignore": []
  }
}
```

## Ignoring Code

There are times when the way we format code might not be ideal. For these cases you can use a format suppression comment:

```js
// rome-ignore format: <explanation>
```

Example:

```js
const expr =
  // rome-ignore format: the array should not be formatted
  [
    (2 * n) / (r - l),
    0,
    (r + l) / (r - l),
    0,
    0,
    (2 * n) / (t - b),
    (t + b) / (t - b),
    0,
    0,
    0,
    -(f + n) / (f - n),
    -(2 * f * n) / (f - n),
    0,
    0,
    -1,
    0,
  ];
```
